<template>
	<view class="">
		<view class="padding-10">
			<u-subsection :list="subsectionList" :current="curNow" keyName="label" @change="sectionChange">
			</u-subsection>
		</view>
		<view class="my-list">
			<u-list :height="swiperHeight" @scrolltolower="scrolltolower" v-if="dataList.length > 0">
				<u-list-item v-for="(item, index) in dataList" :key="index">
					<view class="item fsize-26" @click="$u.route('/pages/order/serviceorder/details?id='+item.id)">
						<view class="flex justify-between">
							<view class="fweigh-600">服务订单: {{item.serviceOrderId}}</view>
							<view class="text-red">￥{{item.rewardAmount || 0}}</view>
						</view>
						<view class="flex pt-20 pb-20">
							<u--image :showLoading="true" class="width-120 height-120" :src="item.user.avatarImage || '/static/logo.png'" shape="circle" width="100rpx" height="100rpx"></u--image>
							<view class="ml-20">
								<view class="">{{item.user.nickName}}</view>
								<view class="mt-10">订单额:￥{{item.project.price}}</view>
							</view>
						</view>
						<view class="flex justify-between">
							<view class="">{{item.createTime}}</view>
						</view>
					</view>
				</u-list-item>
				<u-loadmore :status="loadmore.status" :icon-type="loadmore.iconType" :load-text="loadmore.loadText.loadText" margin-top="0"
					margin-bottom="20" class="coreshop-padding-top-10" />
			</u-list>
		</view>
		<!-- 无数据时默认显示 -->
		<view class="emptybox" v-if="dataList.length == 0">
			<u-empty icon-size="150" text="暂无数据" mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		mixins:[listHeightMixin],
		data() {
			return {
				subsectionList: [
					{ label: '全部', value: '0' }, 
					{ label: '正常', value: '1' },
					{ label: '作废', value: '2' },
					{ label: '完成', value: '5' },
				],
				loadmore:{
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					},
				},
				curNow: 0,
				staffId:0,
				dataList: [],
				searchData: {
					status:0,
					page: 1,
					limit: 10,
					inviteStaffId:0,
				}
			}
		},
		onLoad(option) {
			let that = this
			if (option.id) {
				this.staffId = option.id;
				this.searchData.inviteStaffId = this.staffId;
				this.getPageList(this.staffId);
			}else{
				this.getPageList(0);
			}
			
		},
		methods: {
			sectionChange(index) {
				if (this.curNow === index) return
				this.curNow = index;
				this.searchData = this.$options.data().searchData
				this.searchData.status = this.subsectionList[index].value
				if(this.staffId){
					this.searchData.inviteStaffId = this.staffId;
				}
				this.searchData
				this.dataList = []
				this.getPageList(this.staffId)
			},
			getPageList(staffId) {
				this.$reqPost('ServicesOrderList', this.searchData).then(res => {
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.loadmore.status = 'loadmore';
						this.searchData.page++;
					} else {
						// 数据已加载完毕
						this.loadmore.status = 'nomore';
					}
				})
			},
			scrolltolower() {
				if (this.loadmore.status === 'loadmore') {
					this.getPageList();
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
</style>
